package com.file;

import java.io.File;
import java.io.IOException;

/**
 * Version: 1.1
 * Author: TangJun
 * Date: 2024-07-27
 */
public class Test {
    public static void main(String[] args) {
        //File fileFather = new File("D:\\CScode\\code\\java_code\\2024\\t0727\\src");
        String fileFather = "D:\\CScode\\code\\java_code\\2024\\t0727\\src";
        String fileSon = "b";
        File fileName = new File(fileFather, fileSon);
        //File fileName = new File("D:\\CScode\\code\\java_code\\2024\\t0727\\src\\a\\b\\c");
/*        try {
            fileName.createNewFile();
            System.out.println("创建成功");
        } catch (IOException e) {
            throw new RuntimeException(e);
        }*/
        System.out.println(fileName.getName());
        System.out.println(fileName.getParent());
        System.out.println(fileName.getAbsolutePath());

        if (fileName.exists()) {
            if (fileName.delete()) {
                System.out.println("删除成功");
            } else {
                System.out.println("删除失败");
            }
        } else {
            System.out.println("该文件不存在，删不了");
        }


        if (fileName.exists()) {
            System.out.println("该文件已经存在");
        } else {
            if (fileName.mkdirs()) {
                System.out.println("创建目录成功");
            } else {
                System.out.println("创建目录失败");
            }
        }

    }
}
